import java.util.Arrays;
import java.util.Comparator;
import java.util.Objects;
import java.util.PriorityQueue;

class Student{
    String name;

    public boolean equals(Object o){
        if (this == o)return true;
        if (o == null || getClass()!=o)return false;
        Student student = (Student) o;
        return Objects.equals(name,student.name);
    }

    @Override
    public int hashCode() {
        return Objects.hash(name);
    }
}


class InBig implements Comparator<Integer>{
    public int compare(Integer o1,Integer o2){
        return o1.compareTo(o2);
    }
}

public class Test {
    public static void main(String[] args) {
        PriorityQueue<Integer>minHeap = new PriorityQueue<>(new InBig());
        minHeap.offer(1);
        minHeap.offer(2);
        System.out.println(minHeap.peek());
    }

   public static int[] findKmax(int[] array,int k){
        PriorityQueue<Integer>minHeap = new PriorityQueue<>();
        for (int i=0;i<array.length;i++){
            int top = minHeap.peek();
            if (top<array[i]){
                minHeap.poll();
                minHeap.offer(array[i]);
            }
        }
        int[] ret = new int[k];
        for (int i=0;i<k;i++){
            ret[i] = minHeap.poll();
        }
        return ret;
   }
   public static void main4(String[]args){
        int[] array ={1,13,41,51,61,71,19};
        int[] ret = findKmax(array,3);
       System.out.println(Arrays.toString(ret));
   }

   public int[] find(int[] array,int k){
        PriorityQueue<Integer>minHeap = new PriorityQueue<>();
        for (int i=0;i<array.length;i++){
            minHeap.offer(array[i]);
        }

        int[] ret = new  int[k];
        for (int i=0;i<k;i++){
            ret[i] = minHeap.poll();
        }
        return ret;
   }

    public static void main3(String[] args) {
        PriorityQueue<Integer>priorityQueue = new PriorityQueue<>();
        priorityQueue.offer(null);
    }

    public static void main2(String[] args) {
        //默认是小根堆
        PriorityQueue<Integer> priorityQueue = new PriorityQueue<>();
        priorityQueue.offer(1);
        priorityQueue.offer(3);
        priorityQueue.offer(4);
        priorityQueue.offer(7);

        System.out.println(priorityQueue.peek());
    }

    public static void main1(String[] args) {
        TestHeap testHeap = new TestHeap();
        int[] array ={27,15,19,18,28,34,65,49,25,37};
        testHeap.initEle(array);
        //O(N)
        testHeap.createHeap();
        testHeap.heapSort();
    }
}
